
var app = getApp();
var util = require('../../utils/util.js')
var md5 = require('../md5.js');
Page({
  data: {
    szattendeeid:'',
    currentTab1: 0,
    page: 1,
    curpage0: 1,
    curpage1: 1,
    curpage2: 1,
    showModal: false,
    nail: [0, 0, 0],
    zdynail: [],
    naillist: ['未联系', '无需继续联系', '继续跟进',],
    currentTab: 0,
    showModal: false,
    recommend: '1',
    tjzssx: '0',
    inputVal: '',
    tmpstr: '',
    contentHeight: 1500,
    exportStyle: 0,
    currentId:1,
    currentingId: 1,
    section: [ {
      name: '通讯录',
      typeId: '5'
    }, {
      name: '消息',
      typeId: '6'
    }],
  },
  submit: function () {
    this.setData({
      showModal: true
    })
  },
  submiting: function (e) {
    var delArray = e.currentTarget.dataset.tagid
    var delattendeeid = (delArray.split('-'))[0]
    var delfullname = (delArray.split('-'))[1]
    this.setData({
      delattendeeid: delattendeeid,
      delfullname: delfullname,
      showModaling: true,
    })
  },
  submitingno: function (e) {
    this.setData({
      delattendeeid: '',
      delfullname: '',
      showModaling: false,
    })
  },
  submitingmesgno: function (e) {
    this.setData({
      mesgshowModaling: false,
    })
  },
  mesgsubmiting: function (e) {
    var toid = e.currentTarget.dataset.tagid
    this.setData({
      deltoid: toid,
      mesgshowModaling: true,
    })
  },
  //通讯录里点击切换
  handleTap: function (e) {
    var that = this
    let id = e.currentTarget.id;
    console.log('id=' + id)
    if (id == '1') {
      that.zx()
    }
    if (id == '2') {
      that.tjzs()
    }
    if (id) {
      this.setData({
        currentId: id
      })
    }
  },

  //点击每个导航的点击事件
  handleingTap: function (e) {
    let id = e.currentTarget.id;
    if (id) {
      this.setData({
        currentingId: id
      })
    }
  },

  //左滑动删除
  handleMovableChange: function (e) {
    // this.data.currentX = e.detail.x;
    console.log('左侧滑动删除')
    this.data.currentX = e.detail.x;
  },

  handleTouchend: function (e) {
    console.log('左侧滑动删除111')
    var attid = e.currentTarget.dataset.id
    //console.log('id=' + attid)
    this.isMove = true;
    if (this.data.currentX < -46) {
      console.log('id1111=' + attid)
      this.data.x = -130;
      this.setData({
        x: this.data.x
      });
    } else {
      console.log('id222=' + attid)
      this.data.x = 0;
      this.setData({
        x: this.data.x
      });
    }
  },

  //左滑动删除
  handleMovableChange1: function (e) {
    // this.data.currentX = e.detail.x;
    this.data.currentY = e.detail.y;
  },

  handleTouchend1: function (e) {
    this.isMove = true;
    if (this.data.currentY < -46) {
      this.data.y = -130;
      this.setData({
        y: this.data.y
      });
    } else {
      this.data.y = 0;
      this.setData({
        y: this.data.y
      });
    }
  },
  //底部导航跳转
  toAiIndex: function () {
    util.toAiIndex()
  },
  toContactsIng: function () {
    util.toContactsIng()
  },
  toProductRevision: function () {
    util.toProductRevision()
  },
  toMy: function () {
    util.toMy()
  },
  toBadge: function () {
    util.toBadge()
  },
  exportsub: function () {
    this.setData({
      expModal: true
    })
  },
  exportycsub: function () {
    this.setData({
      expModal: false
    })
  },
  preventTouchMove: function () {

  },

  go: function () {
    this.setData({
      showModal: false
    })
  },
  //滑动切换
  swiperTab1: function (e) {
    var that = this;
    that.setData({
      currentTab1: e.detail.current
    });
  },
  changeStyle: function (e) {
    var that = this;
    var curStyle = that.data.exportStyle
    if (curStyle == 0) {
      that.setData({
        exportStyle: 1
      })
    } else {
      that.setData({
        exportStyle: 0
      })
    }
  },
  expconfirm: function (e) {
    var that = this;
    var curStyle = that.data.exportStyle
    console.log('curStyle=' + curStyle)
    if (curStyle == 0) {
      wx.navigateTo({
        url: '../contactExport/bathExport',
      })
    } else {
      wx.navigateTo({
        url: '../contactExport/bathStorage',
      })
    }
  },
  //点击切换
  clickTab1: function (e) {
    var that = this;
    if (this.data.currentTab1 === e.target.dataset.current1) {
      return false;
    } else {
      that.setData({
        currentTab1: e.target.dataset.current1
      })
    }
  },
  onReady: function (e) {
    this.mapCtx = wx.createMapContext('myMap')
  },
  getCenterLocation: function () {
    this.mapCtx.getCenterLocation({
      success: function (res) {
        console.log(res.longitude)
        console.log(res.latitude)
      }
    })
  },
  reset: function () {
    this.setData({
      nail: [0, 0, 0],
      zdynail: [],
      tmpstr: ''
    })
  },

  preventTouchMove: function () {

  },
  go: function (e) {
    var that = this;
    var kk = that.data.currentTab
    console.log("curtab=", kk)
    var nail = that.data.nail
    //获取选择状态
    var status = ''
    if (nail[0] == '1') {
      status = '0'
    }
    if (nail[1] == '1') {
      status = '1'
    }
    if (nail[2] == '1') {
      status = '2'
    }
    //获取关键词
    var keyword = e.detail.value
    var tmpstr = that.data.tmpstr
    console.log('keyword=' + keyword)
    var recommend = that.data.recommend
    var exhibitionid = wx.getStorageSync('exhibitionid')
    var u = wx.getStorageSync('u')
    var timestamp = Date.parse(new Date());
    timestamp = timestamp / 1000;
    var url = app.globalData.picoaddress + '/attendee/contacts/list'
    var k = {}
    k["v"] = '1.0.0'
    k["client"] = 'ios'
    k["timestamp"] = timestamp
    k["lan"] = 'cn'
    k["exhibitionid"] = exhibitionid
    k["u"] = u
    k["isrecommend"] = '0'
    k["recommend"] = recommend
    var sign = ''
    if (status != '') {
      k["status"] = status
      //判断关键词
      if (keyword != '') {
        k["keyword"] = keyword
        if (tmpstr != '') {
          k["tags"] = tmpstr
          sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0keyword' + keyword + 'recommend' + recommend + 'status' + status + 'tags' + tmpstr + 'timestamp' + timestamp + app.globalData.picotoken
        } else {
          sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0keyword' + keyword + 'recommend' + recommend + 'status' + status + 'timestamp' + timestamp + app.globalData.picotoken

        }
      } else {
        if (tmpstr != '') {
          k["tags"] = tmpstr
          sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0recommend' + recommend + 'status' + status + 'tags' + tmpstr + 'timestamp' + timestamp + app.globalData.picotoken
        } else {
          sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0recommend' + recommend + 'status' + status + 'timestamp' + timestamp + app.globalData.picotoken
        }

      }
    } else {
      if (keyword != '') {
        k["keyword"] = keyword
        if (tmpstr != '') {
          k["tags"] = tmpstr
          sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0keyword' + keyword + 'recommend' + recommend + 'tags' + tmpstr + 'timestamp' + timestamp + app.globalData.picotoken
        } else {
          sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0keyword' + keyword + 'recommend' + recommend + 'timestamp' + timestamp + app.globalData.picotoken
        }

      } else {
        if (tmpstr != '') {
          k["tags"] = tmpstr
          sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0recommend' + recommend + 'tags' + tmpstr + 'timestamp' + timestamp + app.globalData.picotoken
        } else {
          sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0recommend' + recommend + 'timestamp' + timestamp + app.globalData.picotoken
        }

      }
    }
    console.log('sign=' + sign)
    var curb64 = md5.zhMD5(sign)
    console.log(curb64)
    // curb64 = 'ECC8FD59E6E11CFD04E00ADA9ACEA342'
    console.log(curb64)
    k["sign"] = curb64
    wx.request({
      header: {
        'content-type': 'application/x-www-form-urlencoded',
      },
      url: url,
      method: 'post',
      data: k,
      success(res) {
        console.log(res)
        var mesg = res.data
        console.log('mesg=' + mesg)
        var curdata = mesg.data
        console.log('curdata=' + curdata)
        that.setData({
          personMesg: curdata
        });
        var size = curdata.length;
        console.log("size=" + size)
        if (size != 0) {
          var fullname = curdata[0].fullname
          console.log('fullname=' + fullname)
        }

      }, fail: res => {
        console.log(res, "error")
      }
    })
    this.setData({
      showModal: false
    })

  },
  goSearch: function (e) {
    var that = this;
    //重新设置通讯录下拉加载为第一页
    that.setData({
      curpage1: 1
    });
    var kk = that.data.currentTab
    console.log("curtab=", kk)
    var nail = that.data.nail
    //获取选择状态
    var status = ''
    if (nail[0] == '1') {
      status = '0'
    }
    if (nail[1] == '1') {
      status = '1'
    }
    if (nail[2] == '1') {
      status = '2'
    }
    //获取关键词
    var keyword = that.data.inputVal
    var tmpstr = that.data.tmpstr
    console.log('keyword=' + keyword)
    var recommend = that.data.recommend
    var exhibitionid = wx.getStorageSync('exhibitionid')
    var u = wx.getStorageSync('u')
    var timestamp = Date.parse(new Date());
    timestamp = timestamp / 1000;
    var url = app.globalData.picoaddress + '/attendee/contacts/list'
    var k = {}
    k["v"] = '1.0.0'
    k["client"] = 'ios'
    k["timestamp"] = timestamp
    k["lan"] = 'cn'
    k["exhibitionid"] = exhibitionid
    k["u"] = u
    k["isrecommend"] = '0'
    k["recommend"] = recommend
   // k["page"] ='0'
    var sign = ''
    if (status != '') {
      k["status"] = status  
        if (tmpstr != '') {
          k["tags"] = tmpstr
          sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0recommend' + recommend + 'status' + status + 'tags' + tmpstr + 'timestamp' + timestamp + app.globalData.picotoken
        } else {
          sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0recommend' + recommend + 'status' + status + 'timestamp' + timestamp + app.globalData.picotoken
        }
      
    } else {
        if (tmpstr != '') {
          k["tags"] = tmpstr
          sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0recommend' + recommend + 'tags' + tmpstr + 'timestamp' + timestamp + app.globalData.picotoken
        } else {
          sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0recommend' + recommend + 'timestamp' + timestamp + app.globalData.picotoken
        }     
    }
    console.log('sign=' + sign)
    var curb64 = md5.zhMD5(sign)
    console.log(curb64)
    // curb64 = 'ECC8FD59E6E11CFD04E00ADA9ACEA342'
    console.log(curb64)
    k["sign"] = curb64
    wx.request({
      header: {
        'content-type': 'application/x-www-form-urlencoded',
      },
      url: url,
      method: 'post',
      data: k,
      success(res) {
        console.log(res)
        var mesg = res.data
        console.log('mesg=' + mesg)
        var curdata = mesg.data
        console.log('curdata=' + curdata)
        that.setData({
          personMesg: curdata
        });
      }, fail: res => {
        console.log(res, "error")
      }

    })
    //刷新最新
    var url = app.globalData.picoaddress + '/attendee/contacts/list'
    var zxrecommend = '-1'
    var z = {}
    z["v"] = '1.0.0'
    z["client"] = 'ios'
    z["timestamp"] = timestamp
    z["lan"] = 'cn'
    z["exhibitionid"] = exhibitionid
    z["u"] = u
    z["isrecommend"] = '0'
    z["recommend"] = zxrecommend
    //z["page"] ='0'
    var sign = ''
    if (status != '') {
      z["status"] = status  
        if (tmpstr != '') {
          z["tags"] = tmpstr
          sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0recommend' + zxrecommend + 'status' + status + 'tags' + tmpstr + 'timestamp' + timestamp + app.globalData.picotoken
        } else {
          sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0recommend' + zxrecommend + 'status' + status + 'timestamp' + timestamp + app.globalData.picotoken
        }
      
    } else {
        if (tmpstr != '') {
          z["tags"] = tmpstr
          sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0recommend' + zxrecommend + 'tags' + tmpstr + 'timestamp' + timestamp + app.globalData.picotoken
        } else {
          sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0recommend' + zxrecommend + 'timestamp' + timestamp + app.globalData.picotoken
        }     
    }
    console.log('sign=' + sign)
    var curb64 = md5.zhMD5(sign)
    console.log(curb64)
    // curb64 = 'ECC8FD59E6E11CFD04E00ADA9ACEA342'
    console.log(curb64)
    z["sign"] = curb64
    wx.request({
      header: {
        'content-type': 'application/x-www-form-urlencoded',
      },
      url: url,
      method: 'post',
      data: z,
      success(res) {
        console.log(res)
        var mesg = res.data
        console.log('mesg=' + mesg)
        var curdata = mesg.data
        console.log('curdata=' + curdata)
        that.setData({
          zxpersonMesg: curdata
        });
       
      }, fail: res => {
        console.log(res, "error")
      }

    })

    this.setData({
      showModal: false
    })

  },
  onShow: function () {
    var that = this;
    var szattendeeid = that.data.szattendeeid
    console.log('szattendeeid='+szattendeeid)
    var page = that.data.page
    //刷新重新设置值
    that.setData({
      curpage0: 1,
      curpage1: 1,
      curpage2: 1,
    });

    // 页面初始化 options为页面跳转所带来的参数 ,删除联系人跳转过来
    //获取缓存展会id和用户id存在则获取最新联系人列表
    //设置语言0:中文，1：英文
    var setlanguage = wx.getStorageSync('setlanguage')
    if ((wx.getStorageSync('setlanguage') || !"".trim() == wx.getStorageSync('setlanguage'))) {
      this.setData({
        setlanguage: wx.getStorageSync('setlanguage')
      })
      if (setlanguage == 1) {
        wx.setNavigationBarTitle({
          title: 'Contacts'
        })
      } else {
        wx.setNavigationBarTitle({
          title: '联系人'
        })
      }
    } else {
      wx.setStorageSync('setlanguage', 0);
      this.setData({
        setlanguage: 0
      })
    }
    var exhibitionid = wx.getStorageSync('exhibitionid')
    var u = wx.getStorageSync('u')
    console.log('exhibitionid=', exhibitionid)
    console.log('u=', u)
    if ((wx.getStorageSync('exhibitionid') || !"".trim() == wx.getStorageSync('exhibitionid'))
      && (wx.getStorageSync('u') || !"".trim() == wx.getStorageSync('u'))) {
      //默认最新（调用pico接口）
      var timestamp = Date.parse(new Date());
      timestamp = timestamp / 1000;
      var url = app.globalData.picoaddress + '/attendee/contacts/list'
      var k = {}
      k["v"] = '1.0.0'
      k["client"] = 'ios'
      k["timestamp"] = timestamp
      k["lan"] = 'cn'
      k["exhibitionid"] = exhibitionid
      k["u"] = u
      k["isrecommend"] = '0'
      k["page"] = page
      var sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0page' + page + 'timestamp' + timestamp + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      k["sign"] = curb64
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url,
        method: 'post',
        data: k,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          //数据暂不刷新
          var personMesg = that.data.personMesg
          if(!(szattendeeid=='')){
            var curszattendeeid = (szattendeeid.split('-'))[0]
            var curszstatus = (szattendeeid.split('-'))[1]
            console.log('curszattendeeid='+curszattendeeid)
            console.log('curszstatus='+curszstatus)
            for(var i in personMesg){
              if(personMesg[i].attendeeid==curszattendeeid){
                personMesg[i].status = curszstatus
              }
            }
          }
          that.setData({
            personMesg: personMesg
          });
          var size = curdata.length;
          console.log("size=" + size)
          if (size != 0) {
            var attendeeid = curdata[0].attendeeid
            // console.log('attendeeid=' + attendeeid)
            //调用pico标签列表
            var timestamp = Date.parse(new Date());
            timestamp = timestamp / 1000;
            var url = app.globalData.picoaddress + '/attendee/tags/list'
            var k = {}
            k["v"] = '1.0.0'
            k["client"] = 'ios'
            k["timestamp"] = timestamp
            k["lan"] = 'cn'
            k["exhibitionid"] = exhibitionid
            k["attendeeid"] = attendeeid
            k["u"] = u
            var sign = app.globalData.picotoken + 'attendeeid' + attendeeid + 'clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
            console.log(sign)
            var curb64 = md5.hexMD5(sign)
            console.log(curb64)
            k["sign"] = curb64
            wx.request({
              header: {
                'content-type': 'application/x-www-form-urlencoded',
              },
              url: url,
              method: 'post',
              data: k,
              success(res) {
                console.log(res)
                var mesg = res.data
                console.log('mesg=' + mesg)
                var curdata = mesg.data
                that.setData({
                  tagsDetail: curdata
                });
              }, fail: res => {
                console.log(res, "error")
              }
            })
          }

        }, fail: res => {
          console.log(res, "error")
        }

      })
      //========最新暂不刷新数据
      var zxpersonMesg = that.data.zxpersonMesg
      if(!(szattendeeid=='')){
        var curszattendeeid = (szattendeeid.split('-'))[0]
        var curszstatus = (szattendeeid.split('-'))[1]
        console.log('curszattendeeid='+curszattendeeid)
        console.log('curszstatus='+curszstatus)
        for(var i in zxpersonMesg){
          if(zxpersonMesg[i].attendeeid==curszattendeeid){
            zxpersonMesg[i].status = curszstatus
          }
        }
      }
      that.setData({
        zxpersonMesg: zxpersonMesg
      });
      //========好友推荐
      var m = {}
      m["v"] = '1.0.0'
      m["client"] = 'ios'
      m["timestamp"] = timestamp
      m["lan"] = 'cn'
      m["exhibitionid"] = exhibitionid
      m["u"] = u
      m["isrecommend"] = '1'
      m["page"] = page
      var cururl = app.globalData.picoaddress + '/attendee/contacts/list'
      var sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend1page' + page + 'timestamp' + timestamp + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      m["sign"] = curb64
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: cururl,
        method: 'post',
        data: m,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          that.setData({
            friendMesg: curdata
          });

        }, fail: res => {
          console.log(res, "error")
        }

      })
      //==================消息列表
      var p = {}
      p["v"] = '1.0.0'
      p["client"] = 'ios'
      p["timestamp"] = timestamp
      p["lan"] = 'cn'
      p["exhibitionid"] = exhibitionid
      p["u"] = u
      p["page"] = page
      var mesgurl = app.globalData.picoaddress + '/attendee/message/list'
      var sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'page' + page + 'timestamp' + timestamp + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      p["sign"] = curb64
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: mesgurl,
        method: 'post',
        data: p,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          that.setData({
            megStatue: false
          })
          for (var i in curdata) {
            console.log('statue=' + curdata[i].isread)
            //存在未读消息 显示红点
            if (!curdata[i].isread) {
              that.setData({
                megStatue: true
              })
            }
          }
          that.setData({
            acceptMesg: curdata
          });

        }, fail: res => {
          console.log(res, "error")
        }

      })

    } else {
      wx.redirectTo({
        url: '../signInbyPhone/signIn'
      })
    }



  },

  onLoad: function (options) {

    var that = this;
    var page = that.data.page
    // 页面初始化 options为页面跳转所带来的参数 ,删除联系人跳转过来
    //获取缓存展会id和用户id存在则获取最新联系人列表
    //设置语言0:中文，1：英文
    var setlanguage = wx.getStorageSync('setlanguage')
    if ((wx.getStorageSync('setlanguage') || !"".trim() == wx.getStorageSync('setlanguage'))) {
      this.setData({
        setlanguage: wx.getStorageSync('setlanguage')
      })
      if (setlanguage == 1) {
        wx.setNavigationBarTitle({
          title: 'Contacts'
        })
      } else {
        wx.setNavigationBarTitle({
          title: '联系人'
        })
      }
    } else {
      wx.setStorageSync('setlanguage', 0);
      this.setData({
        setlanguage: 0
      })
    }
    var exhibitionid = wx.getStorageSync('exhibitionid')
    var u = wx.getStorageSync('u')
    var recommend ='1'
    console.log('exhibitionid=', exhibitionid)
    console.log('u=', u)
    if ((wx.getStorageSync('exhibitionid') || !"".trim() == wx.getStorageSync('exhibitionid'))
      && (wx.getStorageSync('u') || !"".trim() == wx.getStorageSync('u'))) {
      //默认最新（调用pico接口）
      var timestamp = Date.parse(new Date());
      timestamp = timestamp / 1000;
      var url = app.globalData.picoaddress + '/attendee/contacts/list'
      var k = {}
      k["v"] = '1.0.0'
      k["client"] = 'ios'
      k["timestamp"] = timestamp
      k["lan"] = 'cn'
      k["exhibitionid"] = exhibitionid
      k["u"] = u
      k["isrecommend"] = '0'
      k["recommend"] = recommend
      k["page"] = page
      var sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0page' + page+'recommend'+ recommend+ 'timestamp' + timestamp + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      k["sign"] = curb64
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url,
        method: 'post',
        data: k,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data

          that.setData({
            personMesg: curdata,
          });
          var size = curdata.length;
          console.log("size=" + size)
          if (size != 0) {
            var attendeeid = curdata[0].attendeeid
            // console.log('attendeeid=' + attendeeid)
            //调用pico标签列表
            var timestamp = Date.parse(new Date());
            timestamp = timestamp / 1000;
            var url = app.globalData.picoaddress + '/attendee/tags/list'
            var k = {}
            k["v"] = '1.0.0'
            k["client"] = 'ios'
            k["timestamp"] = timestamp
            k["lan"] = 'cn'
            k["exhibitionid"] = exhibitionid
            k["attendeeid"] = attendeeid
            k["u"] = u
            var sign = app.globalData.picotoken + 'attendeeid' + attendeeid + 'clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
            console.log(sign)
            var curb64 = md5.hexMD5(sign)
            console.log(curb64)
            k["sign"] = curb64
            wx.request({
              header: {
                'content-type': 'application/x-www-form-urlencoded',
              },
              url: url,
              method: 'post',
              data: k,
              success(res) {
                console.log(res)
                var mesg = res.data
                console.log('mesg=' + mesg)
                var curdata = mesg.data
                that.setData({
                  tagsDetail: curdata
                });
              }, fail: res => {
                console.log(res, "error")
              }
            })
          }

        }, fail: res => {
          console.log(res, "error")
        }

      })
      //============================最新
      var zxurl = app.globalData.picoaddress + '/attendee/contacts/list'
      var zxrecommend='-1'
      var z = {}
      z["v"] = '1.0.0'
      z["client"] = 'ios'
      z["timestamp"] = timestamp
      z["lan"] = 'cn'
      z["exhibitionid"] = exhibitionid
      z["u"] = u
      z["isrecommend"] = '0'
      z["recommend"] = zxrecommend
      z["page"] = page
      var sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0page' + page+'recommend'+ zxrecommend+ 'timestamp' + timestamp + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      z["sign"] = curb64
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: zxurl,
        method: 'post',
        data: z,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data

          that.setData({
            zxpersonMesg: curdata
          });

        }, fail: res => {
          console.log(res, "error")
        }

      })
      //========好友推荐
      var m = {}
      m["v"] = '1.0.0'
      m["client"] = 'ios'
      m["timestamp"] = timestamp
      m["lan"] = 'cn'
      m["exhibitionid"] = exhibitionid
      m["u"] = u
      m["isrecommend"] = '1'
      m["page"] = page
      var cururl = app.globalData.picoaddress + '/attendee/contacts/list'
      var sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend1page' + page + 'timestamp' + timestamp + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      m["sign"] = curb64
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: cururl,
        method: 'post',
        data: m,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          that.setData({
            friendMesg: curdata
          });

        }, fail: res => {
          console.log(res, "error")
        }

      })
      //==================消息列表
      var p = {}
      p["v"] = '1.0.0'
      p["client"] = 'ios'
      p["timestamp"] = timestamp
      p["lan"] = 'cn'
      p["exhibitionid"] = exhibitionid
      p["u"] = u
      p["page"] = page
      var mesgurl = app.globalData.picoaddress + '/attendee/message/list'
      var sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'page' + page + 'timestamp' + timestamp + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      p["sign"] = curb64
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: mesgurl,
        method: 'post',
        data: p,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          that.setData({
            megStatue: false
          })
          for (var i in curdata) {
            console.log('statue=' + curdata[i].isread)
            //存在未读消息 显示红点
            if (!curdata[i].isread) {
              that.setData({
                megStatue: true
              })
            }
          }
          that.setData({
            acceptMesg: curdata
          });

        }, fail: res => {
          console.log(res, "error")
        }

      })

    } else {
      wx.redirectTo({
        url: '../signInbyPhone/signIn'
      })
    }

  },
  delAttendeeid: function (e) {
    var that = this
    var attendeeid = that.data.delattendeeid
    var exhibitionid = wx.getStorageSync('exhibitionid')
    var u = wx.getStorageSync('u')
    if ((wx.getStorageSync('exhibitionid') || !"".trim() == wx.getStorageSync('exhibitionid'))
      && (wx.getStorageSync('u') || !"".trim() == wx.getStorageSync('u'))) {
      //默认最新（调用pico接口）
      var timestamp = Date.parse(new Date());
      timestamp = timestamp / 1000;
      var url = app.globalData.picoaddress + '/attendee/contacts/del'
      var k = {}
      k["v"] = '1.0.0'
      k["client"] = 'ios'
      k["timestamp"] = timestamp
      k["lan"] = 'cn'
      k["u"] = u
      k["exhibitionid"] = exhibitionid
      k["attendeeid"] = attendeeid
      var sign = app.globalData.picotoken + 'attendeeid' + attendeeid + 'clientios' + 'exhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      k["sign"] = curb64
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url,
        method: 'post',
        data: k,
        success(res) {
          console.log(res)
          var page = that.data.page
          that.setData({
            showModaling: false,
          })
          var personMesg = that.data.personMesg
          var curarray = []
          var oldpersonMesg = that.data.personMesg
          for (var i = 0; i < oldpersonMesg.length; i++) {
            if (!(attendeeid == oldpersonMesg[i].attendeeid)) {
              console.log('i+attendeeid=' + i + '(' + oldpersonMesg[i].attendeeid + ')')
              curarray.push(oldpersonMesg[i])
            }
          }
          that.setData({
            personMesg: curarray
          })

        }, fail: res => {
          console.log(res, "error")
        }
      })
    }
  },
  delToid: function (e) {
    var that = this
    var toid = that.data.deltoid
    var exhibitionid = wx.getStorageSync('exhibitionid')
    var u = wx.getStorageSync('u')
    if ((wx.getStorageSync('exhibitionid') || !"".trim() == wx.getStorageSync('exhibitionid'))
      && (wx.getStorageSync('u') || !"".trim() == wx.getStorageSync('u'))) {
      //默认最新（调用pico接口）
      var timestamp = Date.parse(new Date());
      timestamp = timestamp / 1000;
      var url = app.globalData.picoaddress + '/attendee/message/del'
      var k = {}
      k["v"] = '1.0.0'
      k["client"] = 'ios'
      k["timestamp"] = timestamp
      k["lan"] = 'cn'
      k["u"] = u
      k["exhibitionid"] = exhibitionid
      k["toid"] = toid
      var sign = app.globalData.picotoken + 'clientios' + 'exhibitionid' + exhibitionid + 'timestamp' + timestamp + 'toid' + toid + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      k["sign"] = curb64
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url,
        method: 'post',
        data: k,
        success(res) {
          console.log(res)
          var page = that.data.page
          that.setData({
            mesgshowModaling: false,
          })
          var curarray = []
          var oldacceptMesg = that.data.acceptMesg
          for (var i = 0; i < oldacceptMesg.length; i++) {
            if (!(toid == oldacceptMesg[i].fromid)) {
              console.log('i+fromid=' + i + '(' + oldacceptMesg[i].fromid + ')')
              curarray.push(oldacceptMesg[i])
            }
          }
          that.setData({
            acceptMesg: curarray
          })

        }, fail: res => {
          console.log(res, "error")
        }
      })
    }
  },
  onReachBottom() {
    // 下拉触底，先判断是否有请求正在进行中
    var that = this
    //滚动条回顶部
    // wx.pageScrollTo({
    //   scrollTop: 0,
    //  })
    //设置 删除按钮隐藏
    var page = that.data.page
    console.log("page=" + page)
    var nail = that.data.nail
    //获取选择状态
    var status = ''
    if (nail[0] == '1') {
      status = '0'
    }
    if (nail[1] == '1') {
      status = '1'
    }
    if (nail[2] == '1') {
      status = '2'
    }
    var tmpstr = that.data.tmpstr
    //设置不同tab页的page,哪页触底哪页增加一页数据
    var curTab = that.data.currentingId
    console.log('curTab=' + curTab)
    var curpage0 = that.data.curpage0
    var curpage1 = that.data.curpage1
    var curpage2 = that.data.curpage2
    if (curTab == 0) {
      curpage0 = that.data.curpage0 + 1
    }
    if (curTab == 1) {
      curpage1 = that.data.curpage1 + 1
    }
    if (curTab == 2) {
      curpage2 = that.data.curpage2 + 1
    }

    console.log("curpage0=" + curpage0)
    console.log("curpage1=" + curpage1)
    console.log("curpage2=" + curpage2)
    console.log("curTab=" + curTab)
    if (curTab == 1) {
      that.setData({
        curpage1: curpage1
      });
    }
    if (curTab == 0) {
      that.setData({
        curpage0: curpage0
      });
    }
    if (curTab == 2) {
      that.setData({
        curpage2: curpage2
      });
    }

    if (!that.loading) {
    //wx.showToast({
    //    title: '下拉加载',
   //     icon: 'success',
 //       duration: 1000
   //   })
      //获取缓存展会id和用户id存在则获取最新联系人列表
      var exhibitionid = wx.getStorageSync('exhibitionid')
      var u = wx.getStorageSync('u')
      console.log('exhibitionid=', exhibitionid)
      console.log('u=', u)
      var recommend = that.data.recommend
      console.log('recommend='+recommend)
      if ((wx.getStorageSync('exhibitionid') || !"".trim() == wx.getStorageSync('exhibitionid'))
        && (wx.getStorageSync('u') || !"".trim() == wx.getStorageSync('u'))) {
        //默认最新（调用pico接口）
        var timestamp = Date.parse(new Date());
        timestamp = timestamp / 1000;
        var url = app.globalData.picoaddress + '/attendee/contacts/list'
        var k = {}
        k["v"] = '1.0.0'
        k["client"] = 'ios'
        k["timestamp"] = timestamp
        k["lan"] = 'cn'
        k["exhibitionid"] = exhibitionid
        k["u"] = u
        k["isrecommend"] = '0'
        k["recommend"] = recommend
        if (curTab == 1) {
          k["page"] = curpage1
        } else {
          k["page"] = page
        }

        var sign = ''
        if (curTab == 1) {
          if (status != '') {
            k["status"] = status
            if (tmpstr != '') {
              k["tags"] = tmpstr
              sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0page' + curpage1 + 'recommend' + recommend + 'status' + status + 'tags' + tmpstr + 'timestamp' + timestamp + app.globalData.picotoken
            } else {
              sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0page' + curpage1 + 'recommend' + recommend + 'status' + status + 'timestamp' + timestamp + app.globalData.picotoken
            }
          } else {
            if (tmpstr != '') {
              k["tags"] = tmpstr
              sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0page' + curpage1 + 'recommend' + recommend + 'tags' + tmpstr + 'timestamp' + timestamp + app.globalData.picotoken
            } else {
              sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0page' + curpage1 + 'recommend' + recommend + 'timestamp' + timestamp + app.globalData.picotoken
            }
          }
          
        } else {
          sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0page' + page + 'timestamp' + timestamp + app.globalData.picotoken
        }

        console.log(sign)
        var curb64 = md5.zhMD5(sign)
        console.log(curb64)
        k["sign"] = curb64
        wx.request({
          header: {
            'content-type': 'application/x-www-form-urlencoded',
          },
          url: url,
          method: 'post',
          data: k,
          success(res) {
            console.log(res)
            var mesg = res.data
            console.log('mesg=' + mesg)
            var curdata = mesg.data
            var curarray = []
            var oldpersonMesg = that.data.personMesg
            for (var i = 0; i < oldpersonMesg.length; i++) {
              curarray.push(oldpersonMesg[i])
            }
            for (var i = 0; i < curdata.length; i++) {
              curarray.push(curdata[i])
            }
            if (curTab == 1) {
              that.setData({
                personMesg: curarray
              })
            }

            var size = curdata.length;
            console.log("size=" + size)
            if (size != 0) {
              var attendeeid = curdata[0].attendeeid
              // console.log('attendeeid=' + attendeeid)
              //调用pico标签列表
              var timestamp = Date.parse(new Date());
              timestamp = timestamp / 1000;
              var url = app.globalData.picoaddress + '/attendee/tags/list'
              var k = {}
              k["v"] = '1.0.0'
              k["client"] = 'ios'
              k["timestamp"] = timestamp
              k["lan"] = 'cn'
              k["exhibitionid"] = exhibitionid
              k["attendeeid"] = attendeeid
              k["u"] = u
              var sign = app.globalData.picotoken + 'attendeeid' + attendeeid + 'clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
              console.log(sign)
              var curb64 = md5.hexMD5(sign)
              console.log(curb64)
              k["sign"] = curb64
              wx.request({
                header: {
                  'content-type': 'application/x-www-form-urlencoded',
                },
                url: url,
                method: 'post',
                data: k,
                success(res) {
                  console.log(res)
                  var mesg = res.data
                  console.log('mesg=' + mesg)
                  var curdata = mesg.data
                  that.setData({
                    tagsDetail: curdata
                  });
                }, fail: res => {
                  console.log(res, "error")
                }
              })
            }
          }, fail: res => {
            console.log(res, "error")
          }

        })
         //============================最新
      var zxurl = app.globalData.picoaddress + '/attendee/contacts/list'
      var zxrecommend='-1'
      var z = {}
      z["v"] = '1.0.0'
      z["client"] = 'ios'
      z["timestamp"] = timestamp
      z["lan"] = 'cn'
      z["exhibitionid"] = exhibitionid
      z["u"] = u
      z["isrecommend"] = '0'
      z["recommend"] = zxrecommend
      if (curTab == 1) {
        z["page"] = curpage1
      } else {
        z["page"] = page
      }

      var sign = ''
      if (curTab == 1) {
        if (status != '') {
          z["status"] = status
          if (tmpstr != '') {
            z["tags"] = tmpstr
            sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0page' + curpage1 + 'recommend' + zxrecommend + 'status' + status + 'tags' + tmpstr + 'timestamp' + timestamp + app.globalData.picotoken
          } else {
            sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0page' + curpage1 + 'recommend' + zxrecommend + 'status' + status + 'timestamp' + timestamp + app.globalData.picotoken
          }
        } else {
          if (tmpstr != '') {
            z["tags"] = tmpstr
            sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0page' + curpage1 + 'recommend' + zxrecommend + 'tags' + tmpstr + 'timestamp' + timestamp + app.globalData.picotoken
          } else {
            sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0page' + curpage1 + 'recommend' + zxrecommend + 'timestamp' + timestamp + app.globalData.picotoken
          }
        }
        
      } else {
        sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0page' + page + 'timestamp' + timestamp + app.globalData.picotoken
      }
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      z["sign"] = curb64
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: zxurl,
        method: 'post',
        data: z,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          var curarray = []
          var oldzxpersonMesg = that.data.zxpersonMesg
          for (var i = 0; i < oldzxpersonMesg.length; i++) {
            curarray.push(oldzxpersonMesg[i])
          }
          for (var i = 0; i < curdata.length; i++) {
            curarray.push(curdata[i])
          }
          if (curTab == 1) {
            that.setData({
              zxpersonMesg: curarray
            })
          }

        }, fail: res => {
          console.log(res, "error")
        }

      })
        //========好友推荐
        var m = {}
        m["v"] = '1.0.0'
        m["client"] = 'ios'
        m["timestamp"] = timestamp
        m["lan"] = 'cn'
        m["exhibitionid"] = exhibitionid
        m["u"] = u
        m["isrecommend"] = '1'
        if (curTab == 0) {
          m["page"] = curpage0
        } else {
          m["page"] = page
        }

        var cururl = app.globalData.picoaddress + '/attendee/contacts/list'

        var sign = ''
        if (curTab == 0) {
          sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend1page' + curpage0 + 'timestamp' + timestamp + app.globalData.picotoken
        } else {
          sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend1page' + page + 'timestamp' + timestamp + app.globalData.picotoken
        }

        console.log(sign)
        var curb64 = md5.hexMD5(sign)
        console.log(curb64)
        m["sign"] = curb64
        wx.request({
          header: {
            'content-type': 'application/x-www-form-urlencoded',
          },
          url: cururl,
          method: 'post',
          data: m,
          success(res) {
            console.log(res)
            var mesg = res.data
            console.log('mesg=' + mesg)
            var curdata = mesg.data
            var curarray = []
            var oldfriendMesg = that.data.friendMesg
            for (var i = 0; i < oldfriendMesg.length; i++) {
              curarray.push(oldfriendMesg[i])
            }
            for (var i = 0; i < curdata.length; i++) {
              curarray.push(curdata[i])
            }
            if (curTab == 0) {
              that.setData({
                friendMesg: curarray
              });
            }


          }, fail: res => {
            console.log(res, "error")
          }

        })
        //==================消息列表
        var p = {}
        p["v"] = '1.0.0'
        p["client"] = 'ios'
        p["timestamp"] = timestamp
        p["lan"] = 'cn'
        p["exhibitionid"] = exhibitionid
        p["u"] = u
        if (curTab == 2) {
          p["page"] = curpage2
        } else {
          p["page"] = page
        }
        var mesgurl = app.globalData.picoaddress + '/attendee/message/list'
        var sign = ''
        if (curTab == 2) {
          sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'page' + curpage2 + 'timestamp' + timestamp + app.globalData.picotoken
        } else {
          sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'page' + page + 'timestamp' + timestamp + app.globalData.picotoken
        }

        console.log(sign)
        var curb64 = md5.hexMD5(sign)
        console.log(curb64)
        p["sign"] = curb64
        wx.request({
          header: {
            'content-type': 'application/x-www-form-urlencoded',
          },
          url: mesgurl,
          method: 'post',
          data: p,
          success(res) {
            console.log(res)
            var mesg = res.data
            console.log('mesg=' + mesg)
            var curdata = mesg.data
            var curarray = []
            var oldacceptMesg = that.data.acceptMesg
            for (var i = 0; i < oldacceptMesg.length; i++) {
              curarray.push(oldacceptMesg[i])
            }
            for (var i = 0; i < curdata.length; i++) {
              curarray.push(curdata[i])
            }
            if (curTab == 2) {
              that.setData({
                acceptMesg: curarray
              })
            }

          }, fail: res => {
            console.log(res, "error")
          }

        })

      } else {
        wx.redirectTo({
          url: '../signInbyPhone/signIn'
        })
      }
    }
  },
  onPullDownRefresh() {
    var that = this;
    var page = 1
    var nail = that.data.nail
    //获取选择状态
    var status = ''
    if (nail[0] == '1') {
      status = '0'
    }
    if (nail[1] == '1') {
      status = '1'
    }
    if (nail[2] == '1') {
      status = '2'
    }
    var tmpstr = that.data.tmpstr


    var curTab = that.data.currentingId
    console.log('curTab=' + curTab)
//刷新重新设置值
    var curpage0 = that.data.curpage0
    var curpage1 = that.data.curpage1
    var curpage2 = that.data.curpage2
    if (curTab == 0) {
      curpage0 = 1
      that.setData({
        curpage0: curpage0
      })
    }
    if (curTab == 1) {
      curpage1 = 1
      that.setData({
        curpage1: curpage1
      })
    }
    if (curTab == 2) {
      curpage2 = 1
      that.setData({
        curpage2: curpage2
      })
    }
  
    // 上拉刷新
    if (!that.loading) {
      wx.showToast({
        title: '数据刷新中',
        icon: 'success',
        duration: 1000
      })
      //获取缓存展会id和用户id存在则获取最新联系人列表
      var exhibitionid = wx.getStorageSync('exhibitionid')
      var u = wx.getStorageSync('u')
      console.log('exhibitionid=', exhibitionid)
      console.log('u=', u)
      //var recommend = that.data.recommend
      //下拉刷新正序排序
      var recommend =that.data.recommend
      if ((wx.getStorageSync('exhibitionid') || !"".trim() == wx.getStorageSync('exhibitionid'))
        && (wx.getStorageSync('u') || !"".trim() == wx.getStorageSync('u'))) {
        //默认最新（调用pico接口）
        var timestamp = Date.parse(new Date());
        timestamp = timestamp / 1000;
        var url = app.globalData.picoaddress + '/attendee/contacts/list'
        var k = {}
        k["v"] = '1.0.0'
        k["client"] = 'ios'
        k["timestamp"] = timestamp
        k["lan"] = 'cn'
        k["exhibitionid"] = exhibitionid
        k["u"] = u
        k["isrecommend"] = '0'
        k["recommend"] = recommend
        k["page"] = page
        
        var sign = ''
        if (status != '') {
          k["status"] = status
          if (tmpstr != '') {
            k["tags"] = tmpstr
            sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0page'+page+'recommend' + recommend + 'status' + status + 'tags' + tmpstr + 'timestamp' + timestamp + app.globalData.picotoken
          } else {
            sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0page' + page +'recommend' + recommend + 'status' + status + 'timestamp' + timestamp + app.globalData.picotoken
          }
        } else {
          if (tmpstr != '') {
            k["tags"] = tmpstr
            sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0page' + page +'recommend' + recommend + 'tags' + tmpstr + 'timestamp' + timestamp + app.globalData.picotoken
          } else {
            sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0page' + page +'recommend' + recommend + 'timestamp' + timestamp + app.globalData.picotoken
          }
        }
  
        console.log(sign)
        var curb64 = md5.zhMD5(sign)
        console.log(curb64)
        k["sign"] = curb64
        wx.request({
          header: {
            'content-type': 'application/x-www-form-urlencoded',
          },
          url: url,
          method: 'post',
          data: k,
          success(res) {
            console.log(res)
            var mesg = res.data
            console.log('mesg=' + mesg)
            console.log('curTab=' + curTab)
            var curdata = mesg.data
            if (curTab == 1) {
              that.setData({
                personMesg: curdata
              })
            }
            var size = curdata.length;
            console.log("size=" + size)
            if (size != 0) {
              var attendeeid = curdata[0].attendeeid
              // console.log('attendeeid=' + attendeeid)
              //调用pico标签列表
              var timestamp = Date.parse(new Date());
              timestamp = timestamp / 1000;
              var url = app.globalData.picoaddress + '/attendee/tags/list'
              var k = {}
              k["v"] = '1.0.0'
              k["client"] = 'ios'
              k["timestamp"] = timestamp
              k["lan"] = 'cn'
              k["exhibitionid"] = exhibitionid
              k["attendeeid"] = attendeeid
              k["u"] = u
              var sign = app.globalData.picotoken + 'attendeeid' + attendeeid + 'clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
              console.log(sign)
              var curb64 = md5.hexMD5(sign)
              console.log(curb64)
              k["sign"] = curb64
              wx.request({
                header: {
                  'content-type': 'application/x-www-form-urlencoded',
                },
                url: url,
                method: 'post',
                data: k,
                success(res) {
                  console.log(res)
                  var mesg = res.data
                  console.log('mesg=' + mesg)
                  var curdata = mesg.data
                  that.setData({
                    tagsDetail: curdata
                  });
                }, fail: res => {
                  console.log(res, "error")
                }
              })
            }
          }, fail: res => {
            console.log(res, "error")
          }

        })
          //============================最新
      var zxurl = app.globalData.picoaddress + '/attendee/contacts/list'
      var zxrecommend='-1'
      var z = {}
      z["v"] = '1.0.0'
      z["client"] = 'ios'
      z["timestamp"] = timestamp
      z["lan"] = 'cn'
      z["exhibitionid"] = exhibitionid
      z["u"] = u
      z["isrecommend"] = '0'
      z["recommend"] = zxrecommend
      z["page"] = page
        
        var sign = ''
        if (status != '') {
          z["status"] = status
          if (tmpstr != '') {
            z["tags"] = tmpstr
            sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0page'+page+'recommend' + zxrecommend + 'status' + status + 'tags' + tmpstr + 'timestamp' + timestamp + app.globalData.picotoken
          } else {
            sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0page' + page +'recommend' + zxrecommend + 'status' + status + 'timestamp' + timestamp + app.globalData.picotoken
          }
        } else {
          if (tmpstr != '') {
            z["tags"] = tmpstr
            sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0page' + page +'recommend' + zxrecommend + 'tags' + tmpstr + 'timestamp' + timestamp + app.globalData.picotoken
          } else {
            sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend0page' + page +'recommend' + zxrecommend + 'timestamp' + timestamp + app.globalData.picotoken
          }
        }
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      z["sign"] = curb64
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: zxurl,
        method: 'post',
        data: z,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          console.log('curTab=' + curTab)
          var curdata = mesg.data
          if (curTab == 1) {
            that.setData({
              zxpersonMesg: curdata
            })
          }

        }, fail: res => {
          console.log(res, "error")
        }

      })
        //========好友推荐
        var m = {}
        m["v"] = '1.0.0'
        m["client"] = 'ios'
        m["timestamp"] = timestamp
        m["lan"] = 'cn'
        m["exhibitionid"] = exhibitionid
        m["u"] = u
        m["isrecommend"] = '1'
        m["page"] = page
        var cururl = app.globalData.picoaddress + '/attendee/contacts/list'
        var sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'isrecommend1page' + page + 'timestamp' + timestamp + app.globalData.picotoken
        console.log(sign)
        var curb64 = md5.hexMD5(sign)
        console.log(curb64)
        m["sign"] = curb64
        wx.request({
          header: {
            'content-type': 'application/x-www-form-urlencoded',
          },
          url: cururl,
          method: 'post',
          data: m,
          success(res) {
            console.log(res)
            var mesg = res.data
            console.log('mesg=' + mesg)
            var curdata = mesg.data
            if (curTab == 0) {
              that.setData({
                friendMesg: curdata
              })
            }
          }, fail: res => {
            console.log(res, "error")
          }

        })
        //==================消息列表
        var p = {}
        p["v"] = '1.0.0'
        p["client"] = 'ios'
        p["timestamp"] = timestamp
        p["lan"] = 'cn'
        p["exhibitionid"] = exhibitionid
        p["u"] = u
        p["page"] = page
        var mesgurl = app.globalData.picoaddress + '/attendee/message/list'
        var sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'page' + page + 'timestamp' + timestamp + app.globalData.picotoken
        console.log(sign)
        var curb64 = md5.hexMD5(sign)
        console.log(curb64)
        p["sign"] = curb64
        wx.request({
          header: {
            'content-type': 'application/x-www-form-urlencoded',
          },
          url: mesgurl,
          method: 'post',
          data: p,
          success(res) {
            console.log(res)
            var mesg = res.data
            console.log('mesg=' + mesg)
            var curdata = mesg.data
            if (curTab == 2) {
              that.setData({
                acceptMesg: curdata
              })
            }
          }, fail: res => {
            console.log(res, "error")
          }

        })

      } else {
        wx.redirectTo({
          url: '../signInbyPhone/signIn'
        })
      }
      // 处理完成后，终止下拉刷新
      wx.stopPullDownRefresh()
    }
  },
  //滑动切换
  swiperTab: function (e) {
    var that = this;
    that.setData({
      currentTab: e.detail.current
    });
  },
  //点击切换
  zx: function (e) {
    console.log('aaaaaaaaaaaaaaaaa')
  },
  tjzs: function (e) {
    var that = this;
    //  that.handleTap(e)
    //默认推荐指数倒叙排列
    var recommend = that.data.recommend
    if (recommend == '0') {
      recommend = '1'
    } else {
      recommend = '0'
    }
    //第一次推荐指数倒叙排列
    var tjzssx = that.data.tjzssx
    console.log('tjzssx', tjzssx)
    if (tjzssx == '0') {
      recommend = '1'
      that.setData({
        tjzssx: '1'
      });
    }
    that.setData({
      recommend: recommend
    });
    var personMesg = that.data.personMesg
    //定义数组进行排序
    var starfiveArray=[]
    var starfourArray = []
    var starthreeArray = []
    var startwoArray = []
    var staroneArray = []
    var starzeroArray = []
    for (var i in personMesg){
      var starCount = personMesg[i].stars
      if (starCount=='5'){
        starfiveArray.push(personMesg[i])
      }
      if (starCount == '4') {
        starfourArray.push(personMesg[i])
      }
      if (starCount == '3') {
        starthreeArray.push(personMesg[i])
      }
      if (starCount == '2') {
        startwoArray.push(personMesg[i])
      }
      if (starCount == '1') {
        staroneArray.push(personMesg[i])
      }
      if (starCount == '0') {
        starzeroArray.push(personMesg[i])
      }

    }
    //根据recommed封装数据
    var resArray=[]
    if (recommend=='0'){
      for (var i in starzeroArray){
        resArray.push(starzeroArray[i])
      }
      for (var i in staroneArray) { 
        resArray.push(staroneArray[i])
      }
      for (var i in startwoArray) { 
        resArray.push(startwoArray[i])
      }
      for (var i in starthreeArray) { 
        resArray.push(starthreeArray[i])
      }
      for (var i in starfourArray) { 
        resArray.push(starfourArray[i])
      }
      for (var i in starfiveArray) { 
        resArray.push(starfiveArray[i])
      }
      that.setData({
        personMesg: resArray
      });
    }
    if (recommend == '1'){
      for (var i in starfiveArray) { 
        resArray.push(starfiveArray[i])
      }
      for (var i in starfourArray) { 
        resArray.push(starfourArray[i])
      }
      for (var i in starthreeArray) { 
        resArray.push(starthreeArray[i])
      }
      for (var i in startwoArray) {
        resArray.push(startwoArray[i])
      }
      for (var i in staroneArray) { 
        resArray.push(staroneArray[i])
      }
      for (var i in starzeroArray) { 
        resArray.push(starzeroArray[i])
      }
      that.setData({
       personMesg: resArray
      });
    }
  },
  nailchoice(e) {
    var that = this;
    that.choice(that, 'nail', e)
    var nail = that.data.nail
    var tmpstr = ''
    console.log(nail)

    for (var i in nail) {
      if (nail[i] == 1) {
        tmpstr += that.data.naillist[i] + ","
      }
    }
    console.log('tmpstr=' + tmpstr)
  },
  choice(that, key, e) {

    var nail = that.data[key]

    console.log('nail=' + nail)
    var it = e.currentTarget.dataset.it
    //其他设置为0
    if (nail[it] == 1) {
      //设置其他为0 
      that.setData({
        nail: [0, 0, 0]
      })
    } else {
      that.setData({
        nail: [0, 0, 0]
      })
      var data = key + '[' + it + ']'
      console.log('data=' + data)
      console.log('nail[it]=' + nail[it])
      console.log('[data]=' + [data])
      if (!nail[it] || nail[it] == 0) {
        that.setData({
          [data]: 1
        })
      } else if (nail[it] == 1) {
        that.setData({
          [data]: 0
        })
      }
    }

  },
  zdynailchoice(e) {
    var that = this;
    that.zdychoice(that, 'zdynail', e)
    var zdynail = that.data.zdynail
    var tmpstr = ''

    for (var i in zdynail) {
      if (zdynail[i] == 1) {
        tmpstr += i + "|"
      }
    }
    console.log('tmpstr=' + tmpstr)
    that.setData({
      'tmpstr': tmpstr
    })
  },
  zdychoice(that, key, e) {
    //设置其他为0 
    var zdynail = that.data[key]
    console.log('zdynail=' + zdynail)
    var it = e.currentTarget.dataset.tagid
    //其他设置为0
    var data = key + '[' + it + ']'
    console.log('data=' + data)
    console.log('zdynail[it]=' + zdynail[it])
    console.log('[data]=' + [data])
    if (!zdynail[it] || zdynail[it] == 0) {
      that.setData({
        [data]: 1
      })
    } else if (zdynail[it] == 1) {
      that.setData({
        [data]: 0
      })
    }
  },
  toDetail(e) {
    console.log(e)
    var attendeeid = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '../pageDetail/pageDetails?attendeeid=' + attendeeid,
    })
  },
  toMesgDetail(e) {
    console.log(e)
    var mesg = e.currentTarget.dataset.tagid
    var attendeeid = (mesg.split('-'))[0]
    var nickname = (mesg.split('-'))[1]
    wx.navigateTo({
      url: '../contactsModule/chat?attendeeid=' + attendeeid + '&nickname=' + nickname,
    })
  },
  toAdd(e) {
    var that = this

    var attendeeid = e.currentTarget.dataset.id
    console.log('attendeeid=' + attendeeid)
    var exhibitionid = wx.getStorageSync('exhibitionid')
    var u = wx.getStorageSync('u')
    var timestamp = Date.parse(new Date());
    timestamp = timestamp / 1000;
    var url = app.globalData.picoaddress + '/attendee/message/frindrequest'
    var k = {}
    k["v"] = '1.0.0'
    k["client"] = 'ios'
    k["timestamp"] = timestamp
    k["lan"] = 'cn'
    k["exhibitionid"] = exhibitionid
    k["u"] = u
    k["toid"] = attendeeid
    var sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + 'toid' + attendeeid + app.globalData.picotoken
    console.log(sign)
    var curb64 = md5.hexMD5(sign)
    console.log(curb64)
    k["sign"] = curb64
    wx.request({
      header: {
        'content-type': 'application/x-www-form-urlencoded',
      },
      url: url,
      method: 'post',
      data: k,
      success(res) {

        wx.showToast({
          title: '成功发送请求！！',
          icon: 'success',
          duration: 1000
        })

        // 改变状态？

        console.log(res)
      }, fail: res => {
        console.log(res, "error")
      }

    })

  },
  //点击切换
  clickTab: function (e) {
    var that = this;
    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab: e.target.dataset.current
      })
    }
  },
  toExport: function (e) {
    var that = this;

  }
})